<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center addressManagement_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub addressManagement_fd0_0'>
					<view class='flex flex-wrap align-center addressManagement_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  addressManagement_fd0_0_c0_c0'>&#xe794;</text>
					</view>
					<text class='addressManagement_fd0_0_c1' v-if=" type=='1'">收货地址</text><text
						class='addressManagement_fd0_0_c1' v-if=" type=='2'">取货地址</text>
					<view class='flex flex-wrap align-center addressManagement_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout addressManagement_flex_1">
				<template v-for='(item,key0) in addressList'>
					<view class='flex flex-direction flex-wrap align-stretch addressManagement_fd1_0'
						@tap.stop="selectAddressFunc(item.aid)" :key='key0'>
						<view class='flex flex-wrap align-center'>
							<text class='addressManagement_fd1_0_c0_c0'>{{item.real_name}}</text>
							<text class='addressManagement_fd1_0_c0_c0'>(</text>
							<text class='addressManagement_fd1_0_c0_c0' v-if=" item.sex=='1'">先生</text><text
								class='addressManagement_fd1_0_c0_c2_1' v-if=" item.sex=='2'">女士</text>
							<text class='addressManagement_fd1_0_c0_c0'>)</text>
							<text class='addressManagement_fd1_0_c0_c4'>{{item.mobile}}</text>
						</view>
						<view class='addressManagement_fd1_0_c1'>
							<!-- <text class='addressManagement_fd1_0_c1_c0'>{{item.address_code}}</text> -->
							<text class='addressManagement_fd1_0_c1_c0'>{{item.detail}}</text>
						</view>
						<view class='flex flex-wrap align-center addressManagement_fd1_0_c2'>
							<view class='flex flex-wrap align-center addressManagement_fd1_0_c2_c0'
								v-if="item.is_default=='1'">
								<image class='addressManagement_fd1_0_c2_c0_c0' mode="aspectFit"
									:src='STATIC_URL+"2.png"'></image>
								<text class='addressManagement_fd1_0_c2_c0_c1'>默认地址</text>
							</view>
							<view class='flex flex-wrap align-center addressManagement_fd1_0_c2_c0'
								@tap.stop="DefaultAddressFunc(item.aid)" v-if="item.is_default=='0'">
								<image class='addressManagement_fd1_0_c2_c0_c0' mode="aspectFit"
									:src='STATIC_URL+"3.png"'></image>
								<text class='addressManagement_fd1_0_c2_c0_c1'>设为默认</text>
							</view>
							<view class='flex flex-wrap align-center addressManagement_fd1_0_c2_c2'
								@tap.stop="assignmentFunc(item.aid)">
								<image class='addressManagement_fd1_0_c2_c2_c0' mode="aspectFit"
									:src='STATIC_URL+"87.png"'></image>
								<text class='addressManagement_fd1_0_c2_c2_c1'>删除</text>
							</view>
							<view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="navigateTo"
								:data-url="`/pages/my/editAddress/editAddress?id=${item.aid}`">
								<image class='addressManagement_fd1_0_c2_c2_c0' mode="aspectFit"
									:src='STATIC_URL+"56.png"'></image>
								<text class='addressManagement_fd1_0_c2_c2_c1'>编辑</text>
							</view>
						</view>
					</view>
				</template>
				<fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
					:listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
			</view>

			<!---flex布局flex布局结束-->
			<benben-popup v-model="popupShow1679736462810" :mask="true" :mask-close-able="true" mode='center'>
				<!---删除地址弹窗flex布局开始-->
				<view class="flex flex-direction flex-wrap align-center addressManagement_flex_2">
					<text class='addressManagement_fd2_0'>确定删除地址？</text>
					<view class='flex flex-wrap align-center addressManagement_fd2_1'>
						<button class='addressManagement_fd2_1_c0' @tap.stop="popupShow1679736462810=false">取消</button>
						<button class='addressManagement_fd2_1_c1' @tap.stop="deteleAddressFunc()">确定</button>
					</view>
				</view>

				<!---删除地址弹窗flex布局结束-->

			</benben-popup>
			<view
				class="flex flex-wrap align-start justify-center benben-position-layout flex addressManagement_flex_3">
				<button class='addressManagement_fd3_0' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/my/addAddress/addAddress?type=${type}`">添加地址</button>

			</view>
			<view :style="{height: '129rpx'}"></view>


		</view>
	</page-body>
</template>
<script>
	import pagingList from '@/common/mixin/paging_list.js';
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},
		mixins: [pagingList],

		data() {
			return {
				"popupShow1679736462810": false,
				"minixPagingListsApi": "",
				"pageingListApiMethod": "",
				"allowOnloadGetList": false,
				"addressList": [],
				"address_id": "",
				"type": ""
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			let {
				type
			} = options
			if (type !== undefined) this.type = type
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.getAddressFunc()
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取地址列表
			getAddressFunc() {
				this.minixPagingListsApi = global.apiUrls.post636f7683cf195;
				this.pageingListApiMethod = 'get';
				this.allowOnloadGetList = false;
				this.pagingListPostDataContent = {
					address_type: this.type
				}
				this.listData = [];
				this.addressList = this.listData;
				this.pagingListToggle();

			},
			//设为默认
			async DefaultAddressFunc(id) {
				//请求方法
				//数据验证

				let data6389ad65f28d9 = await this.$api.post(global.apiUrls.post6389ad65f28d9, {
					address_id: id
				});

				if (data6389ad65f28d9.data.code != 1) {
					this.$message.info(data6389ad65f28d9.data.msg);
					return
				}
				let info6389ad65f28d9 = data6389ad65f28d9.data;


				this.getAddressFunc()
			},
			//地址赋值
			assignmentFunc(id) {
				this.address_id = id;
				this.popupShow1679736462810 = true;
			},
			//删除地址
			async deteleAddressFunc() {
				//请求方法
				//数据验证

				let data636f773e8d763 = await this.$api.dbPost(global.apiUrls.post636f773e8d763, {
					address_id: this.address_id
				});
				if (!data636f773e8d763) return
				if (data636f773e8d763.data.code != 1) {
					this.$message.info(data636f773e8d763.data.msg);
					return
				}
				let info636f773e8d763 = data636f773e8d763.data;


				this.popupShow1679736462810 = false;
				this.getAddressFunc()
			},
			//选择地址
			selectAddressFunc(id) {
				this.address_id = id;
				// if (this.type == '1') {
				// 	uni.$emit('selectAddress', this.address_id)
				// 	this.$urouter.navigateBack(1);
				// }
			},
			pagingListPostData() {
				return this.pagingListPostDataContent
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(246, 246, 246, 1);
		background-size: 100% auto;
	}

	.addressManagement_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.addressManagement_fd0_0_c1 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.addressManagement_fd0_0_c0_c0 {
		font-size: 32rpx;
		color: #333;
	}

	.addressManagement_fd0_0_c0 {
		width: 120rpx;
		height: 88rpx;
	}

	.addressManagement_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.addressManagement_flex_1 {
		padding: 24rpx 24rpx 0rpx 24rpx;
	}

	.addressManagement_fd1_0_c2_c2_c1 {
		color: #999999;
		font-size: 28rpx;
		font-weight: 400;
		margin: 0rpx 0rpx 0rpx 10rpx;
	}

	.addressManagement_fd1_0_c2_c2_c0 {
		width: 30rpx;
		height: 30rpx;
		margin: 3rpx 0rpx 0rpx 0rpx;
	}

	.addressManagement_fd1_0_c2_c2 {
		margin: 0rpx 67rpx 0rpx 0rpx;
	}

	.addressManagement_fd1_0_c2_c0_c1 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 400;
		margin: 0rpx auto 0rpx 16rpx;
	}

	.addressManagement_fd1_0_c2_c0_c0 {
		width: 36rpx;
		height: 36rpx;
	}

	.addressManagement_fd1_0_c2_c0 {
		margin: 0rpx auto 0rpx 0rpx;
	}

	.addressManagement_fd1_0_c2 {
		border-top: 1px solid #eee;
		padding: 24rpx 0rpx 32rpx 0rpx;
	}

	.addressManagement_fd1_0_c1_c0 {
		margin: 16rpx 0rpx 32rpx 0rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
		line-height: 40rpx;
	}

	.addressManagement_fd1_0_c1 {
		margin: 24rpx 0rpx 24rpx 0rpx;
	}

	.addressManagement_fd1_0_c0_c4 {
		color: #1A1A1A;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 40rpx;
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.addressManagement_fd1_0_c0_c2_1 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 500;
		line-height: 32rpx;
	}

	.addressManagement_fd1_0_c0_c0 {
		color: #1A1A1A;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 45rpx;
	}

	.addressManagement_fd1_0 {
		background: #fff;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 32rpx 32rpx 0rpx 32rpx;
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.addressManagement_flex_2 {
		background: #fff;
		margin: 0rpx 105rpx 0rpx 105rpx;
		background-size: #eee;
		border-radius: 25rpx 25rpx 25rpx 25rpx;
	}

	.addressManagement_fd2_1_c1 {
		background: transparent;
		line-height: 45rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor4);
		padding: 24rpx 103rpx 24rpx 99rpx;
	}

	.addressManagement_fd2_1_c0 {
		border-right: 1px solid #EEEEEE;
		background: transparent;
		line-height: 45rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		padding: 24rpx 103rpx 24rpx 103rpx;
	}

	.addressManagement_fd2_1 {
		border-top: 1px solid #eee;
	}

	.addressManagement_fd2_0 {
		padding: 87rpx 0rpx 87rpx 0rpx;
		font-size: 36rpx;
		font-weight: 500;
	}

	.addressManagement_flex_3 {
		width: 750rpx;
		height: 129rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.addressManagement_fd3_0 {
		background: var(--benbenbgColor0);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor3);
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 400;
	}
</style>
